﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BOHVote.BLL;
using System.Data;

namespace BOH.DataManagement
{
    public partial class NewSubjectTestModule : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindDrpSubject();
            }
        }

        public void BindDrpSubject()
        {
            DataSet dst = Subject.getSubject("", "A");
            drpSubject.DataSource = dst.Tables[0].DefaultView;
            drpSubject.DataTextField = "SubjectName";
            drpSubject.DataValueField = "SubjectID";
            drpSubject.DataBind();
            ListItem listitem = new ListItem("", "");
            listitem.Selected = true;
            drpSubject.Items.Add(listitem);
        }

        protected void butSave_Click(object sender, EventArgs e)
        {
            string subjectID = drpSubject.SelectedValue;
            string TestModule = drpTestModule.SelectedValue;
            string testModuleName = SysConfigClass.getTestModuleBySubjectID(subjectID);
            if(string.IsNullOrEmpty(testModuleName))
                SysConfigClass.InsertTestModule(subjectID, TestModule);
            Response.Redirect("TestModuleManage.aspx");
        }
    }
}
